Skip to content

Conversation

@iluuu1994
Copy link
Member

Fixes GH-18000

@iluuu1994 iluuu1994 requested review from arnaud-lb and nielsdos March 7, 2025 22:31
@iluuu1994 iluuu1994 changed the base branch from master to PHP-8.4 March 7, 2025 22:31
Copy link
Member

@nielsdos nielsdos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems right

Copy link
Member

@arnaud-lb arnaud-lb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Thank you!

We have the same issue with __get / __set / __isset:

#[AllowDynamicProperties]
class C {
    public $_;
    public function __set($name, $value)
    {
        var_dump(__METHOD__);
        $this->$name = $value * 2;
    }
}

$rc = new ReflectionClass(C::class);

$obj = $rc->newLazyProxy(function () {
    echo "init\n";
    return new C;
});

function foo(C $c) {
    $c->prop = 1;
    var_dump($c->prop);
}

foo($obj);
string(8) "C::__set"
init
string(8) "C::__set"
int(4)

In this case we may need to set the property guard on the real instance before forwarding to it. I will take care of this.

@iluuu1994
Copy link
Member Author

Ah, I missed that one. Thanks!

@iluuu1994 iluuu1994 closed this in 8254e8d Mar 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Lazy proxy calls set hook twice

3 participants